﻿' •———————————————————————————————————————————————————————————————————————•
' | Copyright © 2011 Robert McGinley                                      |
' |                                                                       |
' | This program is free software: you can redistribute it and/or modify  |
' | it under the terms of the GNU General Public License as published by  |
' | the Free Software Foundation, either version 3 of the License, or     |
' | (at your option) any later version.                                   |
' |                                                                       |
' | This program is distributed in the hope that it will be useful,       |
' | but WITHOUT ANY WARRANTY; without even the implied warranty of        |
' | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
' | GNU General Public License for more details.                          |
' |                                                                       |
' | You should have received a copy of the GNU General Public License     |
' | along with this program.  If not, see <http://www.gnu.org/licenses/>. |
' •———————————————————————————————————————————————————————————————————————•
Imports System.Collections.ObjectModel

Module FilesystemSearchFunctions
    Public Sub FindArchivesInDirectory(ByRef SearchDirectory As String)

    End Sub

    Public Function DirectoryExists(ByRef Directory As String) As Boolean
        If My.Computer.FileSystem.DirectoryExists(Directory) = True Then
            Return True
        Else
            Return False
        End If
    End Function

    Public Function GetFilesInDirectory(ByVal Directory As String) As ReadOnlyCollection(Of String)
        If DirectoryExists(Directory) Then
            'Not converting a ReadOnlyCollection to a List unless I have to...
            'Dim returnFiles As List(Of String)
            Dim files As ReadOnlyCollection(Of String) = My.Computer.FileSystem.GetFiles(Directory)
            'Moving this operation to a separate method
            'Dim SubDirectories As ReadOnlyCollection(Of String) = My.Computer.FileSystem.GetDirectories(Directory)
            'For Each file In files
            'Next
            Return files
        Else
            Throw DirectoryDoesNotExistException
        End If
    End Function

End Module
